require('../css/home.less');
require('../css/commom/basic.css');

document.ready(function () {
    // 轮播图
    var mySwiper = new Swiper ('.swiper-container', {
        loop: true, // 循环模式选项
        
        // 如果需要分页器
        pagination: {
          el: '.swiper-pagination',
        },
      }) 
      utils.footerAll('home')
      // 获取dom
      let rankThree=document.querySelector('.rankThree');
      let numOne=document.querySelector('.numOne');
      let numTwo=document.querySelector('.numTwo');
      let clockThree=document.querySelector('.clockThree');
      let user = JSON.parse(localStorage.getItem('user'))
      let commomBox=document.querySelector(".box");
let boxP=document.querySelector(".boxP");
let icon=document.querySelector('.box div')
let commomBox1=document.querySelector(".box1");
let boxP1=document.querySelector(".boxP1");
let icon1=document.querySelector('.box1 div')
let body=document.querySelector('body');
  
      function numData(){
        // 请求接口
        $http.get('/headPageInfo?userId='+user.userId,function (res) {
          // 熏染页面
          rankThree.innerHTML=res.data.rank;
          numOne.innerHTML=res.data.punchIn;
          numTwo.innerHTML=res.data.insigniaNum;
          // 判断今日是否打卡
          if (res.data.isPunch==='false') {
            clockThree.style.display='block';
          }

        });
      }
      numData();
      // 打卡功能
      clockThree.addEventListener('click',function(){
      //  请求接口
      $http.get('/clockIn?userId='+user.userId,function (res1) {
        if(res1.status===0){
          icon.style.display='block'
          boxP.innerHTML='打卡成功'
          commomBox.classList.add('commomBox');
          setTimeout(function(){
              commomBox.classList.remove('commomBox');
              icon.style.display='none'
              boxP.innerHTML=''
          },2000);
          clockThree.style.display='none';
          numData();
        }
      })
      })
})